package com.snnsh.kjb.lottery.po;

import com.snnsh.kjb.lottery.util.ToVO;
import com.snnsh.kjb.lottery.vo.ProductVO;
import org.springframework.beans.BeanUtils;

/**
 * packageName com.snnsh.kjb.lottery.po
 *
 * @author wick
 * @version V1.0.0
 * @date 2025/5/27
 */
public class ProductPO implements ToVO<ProductVO> {
    private Integer id;

    /**
     * 商品名
     */
    private String name;

    /**
     * 概率
     */
    private Float weight;

    /**
     * 是否展示
     */
    private Integer flag = 1;

    //奖品的总数量，每抽完一次，数量减少1
    private Integer amount = 0;

    //剩余的奖品数量
    private Integer leftAmount = 0;

    public ProductPO() {
    }

    public ProductPO(String name, Float weight, Integer flag, Integer amount) {
        this.name = name;
        this.weight = weight;
        this.flag = flag;
        this.amount = amount;
        this.leftAmount = amount;
    }

    public ProductPO(String name, Float weight, Integer flag) {
        this.name = name;
        this.weight = weight;
        this.flag = flag;
    }

    public ProductPO(Integer id, String name, Float weight, Integer flag) {
        this.id = id;
        this.name = name;
        this.weight = weight;
        this.flag = flag;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Float getWeight() {
        return weight;
    }

    public void setWeight(Float weight) {
        this.weight = weight;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    @Override
    public String toString() {
        return "ProductPO{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", weight=" + weight +
                ", flag=" + flag +
                '}';
    }

    @Override
    public ProductVO toVo() {
        ProductVO productVO = new ProductVO();
        BeanUtils.copyProperties(this,productVO);
        return productVO;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Integer getLeftAmount() {
        return leftAmount;
    }

    public void setLeftAmount(Integer leftAmount) {
        this.leftAmount = leftAmount;
    }
}
